From 402f852af212cb4008fc895b5104ce220d3c23a4 Mon Sep 17 00:00:00 2001
From: Fynn Godau <fynngodau@mailbox.org>
Date: Tue, 23 Apr 2019 18:33:19 +0200
Subject: [PATCH] Implement pan pride colors in cards layout

---
 .../godau/fynn/dsbdirect/table/Adapter.java   | 35 +++++++++++++++----
 1 file changed, 28 insertions(+), 7 deletions(-)

diff --git a/app/src/main/java/godau/fynn/dsbdirect/table/Adapter.java b/app/src/main/java/godau/fynn/dsbdirect/table/Adapter.java
index e632d6b..1c9c48b 100755
--- a/app/src/main/java/godau/fynn/dsbdirect/table/Adapter.java
+++ b/app/src/main/java/godau/fynn/dsbdirect/table/Adapter.java
@@ -22,6 +22,7 @@
 package godau.fynn.dsbdirect.table;
 
 import android.content.Context;
+import android.graphics.Color;
 import android.support.v7.widget.CardView;
 import android.text.Html;
 import android.view.LayoutInflater;
@@ -100,15 +101,18 @@ public class Adapter extends ArrayAdapter<Entry> {
             listView1.setDivider(null);
             listView1.setDividerHeight(0);
 
-            // color card according to status
+            // color card according to position
             CardView cardView = rowView.findViewById(R.id.card);
-
-            if (entry.getAffectedClass().isEmpty() && entry.getLesson().isEmpty() && entry.getReplacementTeacher().isEmpty()) {
-                // info card
-                cardView.setCardBackgroundColor(getContext().getResources().getColor(R.color.colorAccent));
+            if (true) {
+                cardView.setBackgroundColor(getColor(position));
             } else {
-                // not an info card
-                cardView.setCardBackgroundColor(getContext().getResources().getColor(R.color.colorPrimary));
+                if (entry.getAffectedClass().isEmpty() && entry.getLesson().isEmpty() && entry.getReplacementTeacher().isEmpty()) {
+                    // info card
+                    cardView.setCardBackgroundColor(getContext().getResources().getColor(R.color.colorAccent));
+                } else {
+                    // not an info card
+                    cardView.setCardBackgroundColor(getContext().getResources().getColor(R.color.colorPrimary));
+                }
             }
         }
 
@@ -129,6 +133,23 @@ public class Adapter extends ArrayAdapter<Entry> {
         return rowView;
     }
 
+    private int getColor(int position) {
+
+        final int[] panPride = {0xffff218c, 0xfffdd900, 0xff21b1ff};
+        final int[] lesbianPride = {0xffa40061, 0xffb75592, 0xffd063a6, 0xffe4accf, 0xffc54e54, 0xff8a1e04};
+        final int[] biPride = {0xffd70170, 0xff734f95, 0xff0038a9};
+        final int[] transPride = {0xff44cff7, 0xfffba9b8, 0xfffba9b8, 0xff44cff7};
+        final int[] acePride = {0xff000000, 0xff7f7f7f, 0xffcacaca, 0xff660066};
+        final int[] lgbtPride = {0xffe40303, 0xffff8c00, 0xfffdd900, 0xff008026, 0xff004dff, 0xff750787};
+        final int[] germany = {0xff000000, 0xffdd0000, 0xffffce00};
+        final int[] netherlands = {0xffb6182b, 0xffcacaca, 0xff1d4788};
+
+        final int[] pattern = panPride;
+        int positionInColors = position % pattern.length;
+
+        return pattern[positionInColors];
+    }
+
     private void fillField(String s, TextView v) {
         if (s != null && !s.isEmpty()) {
             v.setVisibility(View.VISIBLE);
-- 
2.21.0

